package resultsetextractor;

import entity.User;
import framework.dao.jdbc.callback.ResultSetExtractor;

import java.sql.ResultSet;

public class UserResultSetExtractor implements ResultSetExtractor<User> {
    @Override
    public User extractData(ResultSet rs) throws Exception {
        User user=null;
        if(rs.next()){
            user=new User();
            user.setId(rs.getInt("id"));
            user.setUsername(rs.getString("username"));
            user.setPassword(rs.getString("password"));
            user.setSex(rs.getString("sex"));
            user.setEdu(rs.getString("edu"));
            user.setHob(rs.getString("hobbies"));
            user.setDescription(rs.getString("description"));
            user.setRegistDate(rs.getTimestamp("regist_date"));
            user.setStatus(rs.getString("status"));
        }
        return user;
    }
}
